package ce.com.cenewbluesdk.entity.k3;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by Administrator on 2016/11/21.
 * typedef struct
 * {
 * unsigned char	battery_capacity;
 * }battery_info_struct;
 */
public class Battery_Info_Struct_K3 implements Parcelable{
    int battery;

    public Battery_Info_Struct_K3(int battery) {
        this.battery = battery;
    }

    protected Battery_Info_Struct_K3(Parcel in) {
        battery = in.readInt();
    }

    public static final Parcelable.Creator<Battery_Info_Struct_K3> CREATOR = new Parcelable.Creator<Battery_Info_Struct_K3>() {
        @Override
        public Battery_Info_Struct_K3 createFromParcel(Parcel in) {
            return new Battery_Info_Struct_K3(in);
        }

        @Override
        public Battery_Info_Struct_K3[] newArray(int size) {
            return new Battery_Info_Struct_K3[size];
        }
    };

    public byte[] getBytes() {
        byte[] bytes = new byte[2];
        bytes[0] = (byte) battery;

        return bytes;
    }

    public static Battery_Info_Struct_K3 parseBatteryInfo(byte[] batteryBytes) {
        return new Battery_Info_Struct_K3(batteryBytes[0] & 0xff);
    }

    public int getBattery() {
        return battery;
    }

    public void setBattery(int battery) {
        this.battery = battery;
    }

    @Override
    public String toString() {
        return "Battery_Info_Struct_K3{" +
                "battery=" + battery +
                '}';
    }

    public static int getItemSize() {
        return 1;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(battery);
    }
}
